package com.weetop.aklyscan.activity;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.classic.adapter.BaseAdapterHelper;
import com.classic.adapter.CommonRecyclerAdapter;
import com.weetop.aklyscan.R;
import com.weetop.aklyscan.bean.SendRecordBean;

import java.util.ArrayList;
import java.util.List;

public class SendRecordDialog extends Dialog {
    private Context mContext;
    private TextView back;
    private RecyclerView recyclerView;

    private CommonRecyclerAdapter<SendRecordBean> adapter;
    private List<SendRecordBean> mailList = new ArrayList<>();

    public SendRecordDialog(Context context, List<SendRecordBean> mailList) {
        super(context, R.style.promptDialog);
        setContentView(R.layout.dialog_send_record);
        mContext = context;
        this.mailList = mailList;
        initVar();
        initView();
        initAttr();
        initAction();
    }


    public void initVar() {
    }

    public void initView() {
        back = findViewById(R.id.back);
        recyclerView = findViewById(R.id.recyclerView);
    }

    public void initAttr() {
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        adapter = new CommonRecyclerAdapter<SendRecordBean>(mContext, R.layout.item_send_record, mailList) {
            @Override
            public void onUpdate(BaseAdapterHelper helper, SendRecordBean item, int position) {
                helper.setText(R.id.tv_id, position + 1 + "");
                helper.setText(R.id.tv_time, item.getDeliver_time());
                helper.setText(R.id.tv_name, item.getApply_user_name());
                helper.setText(R.id.tv_page, "1");
                if (item.getPartner_type().equals("1")) {
                    helper.setText(R.id.tv_type, "系统生成");
                } else {
                    helper.setText(R.id.tv_type, "手动填写");
                }
            }
        };
        recyclerView.setAdapter(adapter);
    }

    public void initAction() {
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}
